package com.example.goodpet.my.activity;

import android.content.Intent;
import android.view.View;

import androidx.annotation.Nullable;

import com.example.goodpet.R;
import com.example.goodpet.community.bean.UserTieziInfo;
import com.example.goodpet.my.fragment.MyPetCollectFragment;
import com.example.goodpet.my.fragment.MyTieziCollectFragment;
import com.example.goodpet.base.VPMFragmentActivity;
import com.example.goodpet.my.fragment.MyTieziInfoFragment;
import com.example.goodpet.utils.ActivityManager;

import java.util.ArrayList;

public class MyPetCollectActivity extends VPMFragmentActivity {

    @Override
    protected void initListener() {
        cmTitleLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityManager.getInstance().removeCurrent();
            }
        });
    }

    @Override
    protected int setTabTitle() {
        return R.array.user_info_tab;
    }

    @Override
    protected void initTitle() {
        cmTitleText.setText("收藏");
        cmTextRight.setVisibility(View.INVISIBLE);
    }


    @Override
    public void setFragmentList() {
        fragmentList=new ArrayList<>();
        fragmentList.add(new MyPetCollectFragment());
        fragmentList.add(new MyTieziCollectFragment());
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode==RESULT_OK)
            if (requestCode==1){
                UserTieziInfo info = data.getParcelableExtra("info");
                int position = data.getIntExtra("position", -1);
                if (position!=-1 && info!=null) ((MyTieziCollectFragment)fragmentList.get(1)).refresh(position,info);
            }
    }


}